package com.adong;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author adong
 */
public class HelloServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {


    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }
    //
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("service被访问!");
        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
        String method = httpServletRequest.getMethod();
        if ("POST".equals(method)) {
            post();
        } else if ("GET".equals(method)) {
            get();
        }
    }
    private void post(){
        System.out.println("大家好,我是post");
    }
    private void get(){
        System.out.println("大家好,我是get");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
